package main

import (
	"fmt"
	"time"
)

var quit2 chan int

func foo(id int){
	fmt.Println(id)
	time.Sleep(time.Second) //停顿一秒
	quit2 <- 0
}
//并发模式
func main(){
	count := 1000
	quit2 = make(chan int,count) //缓冲1000个数据

	for i := 0; i < count; i++{ //开1000个goroutine
		go foo(i)
	}

	for i := 0; i < count; i++{
		<- quit2
	}

}
// 编译：go build test.go
